#include "mouseitem.h"
#include "handlermouse.h"
#include <QCursor>
#include <QGraphicsSceneMouseEvent>
#include <QDebug>

MouseItem::MouseItem()
{
    itemOriginal = new QPixmap(":/mouse/images/mouseOriginal.png");
    mouseUp = new QPixmap(":/mouse/images/mouseUp.png");
    mouseDown = new QPixmap(":/mouse/images/mouseDown.png");

    setPixmap(*itemOriginal);
    isMouse = false;
    isStart = false;
}

void MouseItem::setStart(bool judge)
{
    isStart = judge;
}

void MouseItem::setMouseUp()
{
    setPixmap(*mouseUp);
}

void MouseItem::setMouseDown()
{
    setPixmap(*mouseDown);
}

void MouseItem::setOriginl()
{
    setPixmap(*itemOriginal);
}

void MouseItem::setMouseStatus(bool judge)
{
    isMouse = judge;
}

void MouseItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    setCursor(QCursor(QPixmap(":/hammer/images/hammerUp.png")));
}

void MouseItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    setCursor(QCursor(QPixmap(":/hammer/images/hammerDown.png")));

    HandlerMouse *hm = HandlerMouse::getInstance();
    if(isMouse && isStart)
    {
        hm->addScore();
        setMouseDown();
        isMouse = false;
    }
}

void MouseItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    setCursor(QCursor(QPixmap(":/hammer/images/hammerUp.png")));
}
